package com.thrc.borrow.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.thrc.borrow.dao.MenuDao;
import com.thrc.borrow.entity.Menu;
import com.thrc.borrow.vo.MenuVo;


@Service
public class MenuService implements BaseService<Menu, MenuVo> {

	@Autowired
	private MenuDao menuDao;

	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public MenuVo selectById(Menu t) {
		return menuDao.selectById(t);
	}

	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<MenuVo> selectAll(Menu t) {
		return menuDao.selectAll(t);
	}

	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<MenuVo> selectByPage(Menu t) {
		t.setStartRow(t.getPageIndex(), t.getPageSize());
		return menuDao.selectByPage(t);
	}

	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void update(Menu t) {
		menuDao.update(t);
	}

	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void delete(Menu t) {
		menuDao.delete(t);
	}

	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void insert(Menu t) {
		menuDao.insert(t);
	}

	@Override
	public int selectCount(Menu t) {
		return menuDao.selectCount(t);
	}

	public List<MenuVo> selectAllMenuByPhone(String phone) {
		return menuDao.selectAllMenuByPhone(phone);
	}

}
